package com.game.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class SwingTest extends JFrame{
	public SwingTest() {
		GuiFactory.createExitDialog(this, true, null);
		JButton showDialog = new JButton("show");
		showDialog.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				double w = getSize().getWidth();
				double h = getSize().getHeight();
				GuiFactory.exitDialog.setPreferredSize(new Dimension((int) (w * 0.3f), (int) (h * 0.2f)));
				GuiFactory.exitDialog.pack();
				int x = (int) ((getSize().getWidth() - GuiFactory.exitDialog.getSize().getWidth()) / 2) + getX();
				int y = (int) ((getSize().getHeight() - GuiFactory.exitDialog.getSize().getHeight()) / 2) + getY();
				GuiFactory.exitDialog.setLocation(x, y);
				GuiFactory.exitDialog.setVisible(true);
			}
		});
		this.add(showDialog);
		this.setSize(600, 400);
		this.setVisible(true);
	}
	public static void main(String[] a){
		SwingTest swingTest = new SwingTest();
	}
}
